<template>
   <a-modal :visible="show" :title="title"  @cancel='close'  :footer="null">
      <p v-for='item in dataList' >
        <a-radio-group v-model="item.isShowAddress" button-style="solid" @change='saveData(item)' >
          <a-radio-button value="true"> 正常 </a-radio-button>
          <a-radio-button value="false"> 停止 </a-radio-button>
        </a-radio-group>
        <span style='margin-left:20px;max-width:330px;display:inline-block;'>{{ item.supplyAddressName }}</span>
      </p>
    </a-modal>
</template>

<script>

import { httpAction, getAction } from '@/api/manage'

export default {
    name: 'HcMerchantAddressDetailModal',
    props: {
      show: {
        type: Boolean,
        default: false,
      },
      addressId: {
        type: String,
        default: '',
      },
      merchantId: {
        type: String,
        default: '',
      },
      title: {
        type: String,
        default: '',
      },
    },
    data() {
      return {
        dataList: [],
      }
    },
    computed: {
      
      
    },
    watch: {
      show(val) {
        if (val) {
          this.getData();
        }
      },
    },

    created() {
      // this.getData();
    },

    methods: {

      // 大厦的启用与关闭
      getData() {
        let url = '/hc/hcSiteAddressDetails/getListByAddressId'
        let param = {
          addressId: this.addressId,
          merchantId: this.merchantId,
        }
        getAction(url, param, 'get')
          .then((res) => {
            this.dataList = [];
            if (res.success) {
              console.log('成功：', res);
              this.dataList = res.result || [];
            }
          })
      },

      // 保存修改
      saveData(item) {
        let url = '/hc/hcSiteAddressDetails/editAddressShowState'
        item.merchantId = this.merchantId;
        httpAction(url, item, 'post')
          .then((res) => {
            if (res.success) {
              // this.$message.success('保存成功')
            } else {
              this.$message.warn('接口异常')
              console.error(res.message);
            }
          })
      },

      close() {
        this.$emit('handleCloseDetailModal')
      },

    }
  }
</script>

<style lang="scss" scoped>

 
</style>